/*
 * Android Runner is a multiplayer GPS game fully written by Xurxo Mendez Perez
 * 
 * Copyright (C) 2009 Xurxo Mendez Perez
 *   
 * This file is part of Android Runner.
 * 
 * Android Runner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Android Runner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Android Runner.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.sonxurxo.androidrunner.model.service.game;

import java.util.List;

import es.sonxurxo.androidrunner.model.persistence.util.exceptions.DuplicateInstanceException;
import es.sonxurxo.androidrunner.model.persistence.util.exceptions.InstanceNotFoundException;
import es.sonxurxo.androidrunner.model.service.game.to.AnswerQuestionResponseTO;
import es.sonxurxo.androidrunner.model.service.game.to.CreateGameTO;
import es.sonxurxo.androidrunner.model.service.game.to.FinishedGameTO;
import es.sonxurxo.androidrunner.model.service.game.to.GameTO;
import es.sonxurxo.androidrunner.model.service.game.to.GameTOCTO;
import es.sonxurxo.androidrunner.model.service.game.to.GetItemResponseTO;
import es.sonxurxo.androidrunner.model.service.game.to.InGamePlayerInfoTO;
import es.sonxurxo.androidrunner.model.service.game.to.MessageTO;
import es.sonxurxo.androidrunner.model.service.game.to.ObserveGameResponseTO;
import es.sonxurxo.androidrunner.model.service.game.to.PlayerAnswerTO;
import es.sonxurxo.androidrunner.model.service.game.to.QuestionTO;
import es.sonxurxo.androidrunner.model.service.game.to.StartOrContinueGameResponseTO;
import es.sonxurxo.androidrunner.model.service.game.to.UpdateLocationResponseTO;
import es.sonxurxo.androidrunner.model.service.game.util.exception.MaxUsersReachedException;
import es.sonxurxo.androidrunner.model.service.game.util.exception.TimeOutException;

/**
 * 
 * @author "Xurxo Mendez Perez"
 *
 */
public interface GameService {

	public GameTO findGameById(long gameId) throws InstanceNotFoundException;

	public GameTOCTO findGamesByCity(String city, int startIndex, int count);
	
	public List<String> findCitiesWithGames();

	public GameTOCTO findGamesByLocation(int latitude, int longitude, int accurate, 
			int startIndex, int count);
	
	public boolean joinGame(String login, long gameId)
	throws InstanceNotFoundException, MaxUsersReachedException, 
	TimeOutException;

	public void abandonGame(String login, long gameId)
	throws InstanceNotFoundException;

	public StartOrContinueGameResponseTO startOrContinueGame(String login)
	throws InstanceNotFoundException, TimeOutException;
	
	public GetItemResponseTO getItem(String login, long itemId, 
			InGamePlayerInfoTO inGamePlayerInfoTO)
	throws InstanceNotFoundException, DuplicateInstanceException;

	public AnswerQuestionResponseTO answerQuestion(String login, 
			PlayerAnswerTO playerAnswerTO, InGamePlayerInfoTO inGamePlayerInfoTO)
	throws InstanceNotFoundException;
	
	public void playerSendsMessage(String login, 
			MessageTO messageTO)
	throws InstanceNotFoundException, DuplicateInstanceException;
	
	public UpdateLocationResponseTO updateLocation(String login, 
			InGamePlayerInfoTO inGamePlayerInfoTO, boolean checkIfFinished)
	throws InstanceNotFoundException;
	
	public GameTO createGame(CreateGameTO createGameTO);
	
	public ObserveGameResponseTO observeGame(long gameId, List<Long> excludedIds)
	throws InstanceNotFoundException ;
	
	public List<GameTO> findActiveGames(int startIndex, int count);
	
	public Integer countActiveGames();
	
	public List<GameTO> findNotFinishedGames(int startIndex, int count);
	
	public Integer countNotFinishedGames();
	
	public void createQuestion(QuestionTO questionTO) throws DuplicateInstanceException;
	
	public List<FinishedGameTO> findFinishedGames(int startIndex, int count);
	
	public Integer countFinishedGames();
	
	public FinishedGameTO findFinishedGameById(long gameId) throws InstanceNotFoundException;
}
